﻿using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;

namespace SaiLing.SingleSignOn.Repository.Migrations
{
    public partial class add_user_position : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "SaiLing_System_UserPosition",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    AccountId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    PositionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SaiLing_System_UserPosition", x => x.Id);
                    table.ForeignKey(
                        name: "FK_SaiLing_System_UserPosition_SaiLing_System_Account_AccountId",
                        column: x => x.AccountId,
                        principalTable: "SaiLing_System_Account",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_SaiLing_System_UserPosition_SaiLing_System_Position_PositionId",
                        column: x => x.PositionId,
                        principalTable: "SaiLing_System_Position",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_SaiLing_System_UserPosition_AccountId",
                table: "SaiLing_System_UserPosition",
                column: "AccountId");

            migrationBuilder.CreateIndex(
                name: "IX_SaiLing_System_UserPosition_PositionId",
                table: "SaiLing_System_UserPosition",
                column: "PositionId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "SaiLing_System_UserPosition");
        }
    }
}
